var a = getApp();

Page({
    data: {
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        member: {},
        totalPrice: "",
        withdraw_amount: 0
    },
    onLoad: function(a) {
        this.getListData();
    },
    getListData: function() {
        var t = this, e = a.getNetAddresss("plugin.consumer-reward.frontend.controllers.reward.reward-record");
        a._postNetWork({
            url: e,
            success: function(e) {
                var o = e.data;
                if (1 != o.result) return a.tips(o.msg);
                t.data.total_page = o.data.reward_record.last_page, t.data.total_page || (t.data.total_page = 0), 
                t.setData({
                    member: o.data.member,
                    listData: o.data.reward_record.data,
                    totalPrice: o.data.total,
                    withdraw_amount: o.data.withdraw_amount
                }), wx.setNavigationBarTitle({
                    title: o.data.plugin_name || "消费奖励"
                });
            }
        });
    },
    gotoWithdraw: function() {
        var t = this, e = a.getNetAddresss("plugin.consumer-reward.frontend.controllers.reward.receive-income");
        a._getNetWork({
            url: e,
            data: {},
            success: function(a) {
                var e = a.data;
                wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1500
                }), 1 == e.result && t.getListData();
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = a.getNetAddresss("plugin.consumer-reward.frontend.controllers.reward.reward-record");
            a._postNetWork({
                url: e,
                data: {
                    page: this.data.page
                },
                success: function(a) {
                    var e = a.data;
                    if (t.data.isLoadMore = !0, 1 === e.result) {
                        var o = t.data.listData.concat(e.data.reward_record.data);
                        t.setData({
                            listData: o
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    gotoConsumerRewardApply: function() {
        wx.navigateTo({
            url: "/packageH/consumerReward/consumerRewardApply/consumerRewardApply"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});